﻿using Microsoft.AspNetCore.Http;

namespace Luka;

/// <summary>
/// 返回值模型
/// </summary>
[NotScanned]
public sealed class BaseResult
{
    /// <summary>
    /// 成功
    /// </summary>
    /// <returns></returns>
    internal static BaseResult SetSuccessed(object? data, int code = StatusCodes.Status200OK) => new()
    {
        Code = code,
        Message = "接口响应成功",
        Data = data,
        ResponseTime = DateTime.Now.ToString()
    };

    /// <summary>
    /// 失败
    /// </summary>
    /// <returns></returns>
    internal static BaseResult SetFailed(string? message = "接口响应失败", int code = StatusCodes.Status400BadRequest) => new()
    {
        Code = code,
        Message = message ?? "接口响应失败",
        ResponseTime = DateTime.Now.ToString()
    };

    /// <summary>
    /// 响应代码
    /// </summary>
    public int Code { get; set; }

    /// <summary>
    /// 消息
    /// </summary>
    public string? Message { get; set; }

    /// <summary>
    /// 数据
    /// </summary>
    public object? Data { get; set; }

    /// <summary>
    /// 响应时间
    /// </summary>
    public string? ResponseTime { get; set; }
}